<?php
/**
 * Psa_Fatal_Error_Exception class.
 * 
 * LICENSE:
 * 
 * This library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with This library. If not, see <{@link http://www.gnu.org/licenses/}>.
 *
 * @link http://code.google.com/p/phpstartapp/
 * @author Bojan Mauser <bmauser@gmail.com>
 * @copyright Bojan Mauser 2009
 * @package psa
 * @subpackage exceptions
 * @version $Id: Psa_User.class.php 158 2008-11-28 17:43:35Z bmauser $
 */


/*
 * Psa_Exception class
 */
include_once 'Psa_Exception.class.php';


/**
 * Psa_Fatal_Error_Exception class.
 * If you raise <kbd>Psa_Fatal_Error_Exception</kbd> exception anywhere in application
 * execution of the script will be terminated and message you provide as first argument 
 * to constructor will be logged.
 * 
 * <b>Example:</b>
 * <code>
 * class example_model extends Psa_Plugin_Model {
 * 
 * 	function example_method(){
 * 
 * 		// some code
 * 		
 * 		// silently die and write message to log
 * 		if($fatal_error)
 * 			throw new Psa_Fatal_Error_Exception('This message will be in logs');
 * 	}
 * }
 * </code>
 */
class Psa_Fatal_Error_Exception extends Psa_Exception{

	/**
	 * Constructor
	 * 
	 * @param string $log_message message to be logged
	 * @param string $echo_message message to be sent to output
	 * @param string $code user defined exception code
	 * @param bool $write_log set to false if you don't want to write exception to log
	 */
	public function __construct($log_message, $echo_message = null, $code = 0, $write_log = true){

		// make sure everything is assigned properly
		parent::__construct($log_message, $code, $write_log);
			
		exit($echo_message);
	}
}

